#include<bits/stdc++.h>
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
struct
{
	using T = ll; T v[400009]; int l;
	inline void clear() { l = 0; }
	inline void push(T x) { v[++l] = x; }
	inline void build() { sort(v + 1, v + l + 1), l = unique(v + 1, v + l + 1) - v - 1; }
	inline int pre(T x)const { return upper_bound(v + 1, v + l + 1, x) - v - 1; }
	inline int nxt(T x)const { return lower_bound(v + 1, v + l + 1, x) - v; }
	inline int id(T x)const { return nxt(x); }
	inline int len()const { return l; }
	inline T val(int x)const { return v[x]; }
}	d;
namespace ST
{
	struct node
	{
		int c; ll s, spre, ssuf;
	}	t[400009 << 2];
	inline int lc(int p) { return p << 1; }
	inline int rc(int p) { return p << 1 | 1; }
	inline int md(int l, int r) { return ( l + r ) >> 1; }
	inline void pu(int p)
	{
		t[p].c = t[lc(p)].c + t[rc(p)].c, t[p].s = t[lc(p)].s + t[rc(p)].s;
		t[p].spre = t[lc(p)].spre + t[rc(p)].spre + t[lc(p)].s * t[rc(p)].c;
		t[p].ssuf = t[lc(p)].ssuf + t[rc(p)].ssuf + t[rc(p)].s * t[lc(p)].c;
	}
	inline void flip(int p, int l, int r, int pos)
	{
		if ( l == r )
		{
			if ( t[p].c ) t[p].c = t[p].s = t[p].spre = t[p].ssuf = 0;
			else t[p].c = 1, t[p].s = t[p].spre = t[p].ssuf = d.val(l); return;
		}
		pos <= md(l, r) ? flip(lc(p), l, md(l, r), pos) : flip(rc(p), md(l, r) + 1, r, pos), pu(p);
	}
	inline ll qrypre(int p, int l, int r, int len)
	{
		if ( len >= t[p].c ) return t[p].s;
		if ( len <= t[lc(p)].c ) return qrypre(lc(p), l, md(l, r), len);
		return t[lc(p)].s + qrypre(rc(p), md(l, r) + 1, r, len - t[lc(p)].c);
	}
	inline ll qrysuf(int p, int l, int r, int len)
	{
		if ( len >= t[p].c ) return t[p].s;
		if ( len <= t[rc(p)].c ) return qrysuf(rc(p), md(l, r) + 1, r, len);
		return t[rc(p)].s + qrysuf(lc(p), l, md(l, r), len - t[rc(p)].c);
	}
	inline pair < int, ll > qryspre(int p, int l, int r, int len)
	{
		if ( len >= t[p].c ) return make_pair(t[p].c, t[p].spre);
		if ( len <= t[lc(p)].c ) return qryspre(lc(p), l, md(l, r), len);
		auto z = qryspre(rc(p), md(l, r) + 1, r, len - t[lc(p)].c);
		return make_pair(z.first + t[lc(p)].c, z.second + t[lc(p)].spre + t[lc(p)].s * z.first);
	}
	inline pair < int, ll > qryssuf(int p, int l, int r, int len)
	{
		if ( len >= t[p].c ) return make_pair(t[p].c, t[p].ssuf);
		if ( len <= t[rc(p)].c ) return qryssuf(rc(p), md(l, r) + 1, r, len);
		auto z = qryssuf(lc(p), l, md(l, r), len - t[rc(p)].c);
		return make_pair(z.first + t[rc(p)].c, z.second + t[rc(p)].ssuf + t[rc(p)].s * z.first);
	}
}
inline ll pre(int x) { return x ? ST::qrypre(1, 1, d.len(), x) : 0; }
inline ll suf(int x) { return x ? ST::qrysuf(1, 1, d.len(), x) : 0; }
inline ll spre(int x) { return x ? ST::qryspre(1, 1, d.len(), x).second : 0; }
inline ll ssuf(int x) { return x ? ST::qryssuf(1, 1, d.len(), x).second : 0; }
inline ll spre(int l, int r) { return l > r ? 0 : spre(r) - spre(l - 1); }
inline ll ssuf(int l, int r) { return l > r ? 0 : ssuf(r) - ssuf(l - 1); }
int q, o, l, r, md, p; ll x[400009], ans;
int main()
{
	freopen("kte.in", "r", stdin), freopen("kte.out", "w", stdout);
	cin.tie(nullptr) -> sync_with_stdio(false);
	cin >> q;
	For(i, 1, q) cin >> x[i], d.push(x[i]); 
	d.build();
	For(i, 1, q)
	{
		x[i] = d.id(x[i]), ST::flip(1, 1, d.len(), x[i]);
		if ( ST::t[1].c < 2 ) { cout << "0\n"; continue; }
		o = ( ST::t[1].c + 2 ) >> 1, ans = ST::t[1].ssuf;
		for ( l = 0, r = o ; l < r ; ) md = ( l + r + 1 ) >> 1,
			pre(md) > suf(md - 1) ? l = md : r = md - 1;
		p = l, ans -= spre(1, l);
		for ( l = o + 1, r = ST::t[1].c ; l < r ; ) md = ( l + r ) >> 1,
			pre(md) > suf(md - 1) ? r = md : l = md + 1;
		ans -= spre(l, d.len()) + ssuf(p, l - 2), cout << ans << '\n';
	}
	return 0;
}